package com.yopinclub;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.LinearLayout.LayoutParams;

import com.yopinclub.activity.SpringBoardActivity;

public class YopinClubAvtivity extends Activity {

	RelativeLayout	mTitleView;
	Button			mButtonSpringBoard;
	ProgressBar		mProgressBarLoading;
	Button			mButtonRefresh;
	RelativeLayout	mContentView;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		super.setContentView(R.layout.activity_yopinclub);

		mTitleView = (RelativeLayout) findViewById(R.id.relative_title);
		mButtonSpringBoard = (Button) findViewById(R.id.btn_main);
		mProgressBarLoading = (ProgressBar) findViewById(R.id.progress_loading);
		mButtonRefresh = (Button) findViewById(R.id.btn_refresh);
		mContentView = (RelativeLayout) findViewById(R.id.relative_content);

		mButtonSpringBoard.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getApplicationContext(),SpringBoardActivity.class);
				intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
			}
		});
	}

	@Override
	public void setContentView(int layoutResID) {
		View view = getLayoutInflater().inflate(layoutResID, null);
		view.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		mContentView.addView(view);
	}

	public void setBackgroundResource(int resId) {
		LinearLayout main = (LinearLayout) findViewById(R.id.linear_main);
		main.setBackgroundResource(resId);
	}

	public void setBackgroundDrawable(Drawable drawable) {
		LinearLayout main = (LinearLayout) findViewById(R.id.linear_main);
		main.setBackgroundDrawable(drawable);
	}

	public void setBackgroundColor(int color) {
		LinearLayout main = (LinearLayout) findViewById(R.id.linear_main);
		main.setBackgroundColor(color);
	}

	public void setNoTitleBar(boolean noTitle) {
		if (noTitle) {
			mTitleView.setVisibility(View.GONE);
		} else {
			mTitleView.setVisibility(View.VISIBLE);
		}
	}

	public void setNoSpringBoardButton(boolean noSpringBoardButton) {
		if (noSpringBoardButton) {
			mButtonSpringBoard.setVisibility(View.GONE);
		} else {
			mButtonSpringBoard.setVisibility(View.VISIBLE);
		}
	}

	public void setNoProgressBar(boolean noProgressBar) {
		if (noProgressBar) {
			mProgressBarLoading.setVisibility(View.GONE);
		} else {
			mProgressBarLoading.setVisibility(View.VISIBLE);
		}
	}

	public void setNoRefreshButton(boolean noRefreshButton) {
		if (noRefreshButton) {
			mButtonRefresh.setVisibility(View.GONE);
		} else {
			mButtonRefresh.setVisibility(View.VISIBLE);
		}
	}

	public void setSpringBoardButtonClickListener(View.OnClickListener listener) {
		mButtonSpringBoard.setOnClickListener(listener);
	}

	public void setRefreshButtonClickListener(View.OnClickListener listener) {
		mButtonRefresh.setOnClickListener(listener);
	}
}
